
const express=require(`express`)

const path =require(`path`)

const app=express()

//中间件功能
app.use(express.urlencoded())
app.use(express.json())



//查
app.get(`/get1`,(request,response)=>{


  // console.log(request.query); //001
  // // console.log(request.query.params);
 
  const {params} =request.query
  // console.log(params);
  // // console.log(userId);
  if (params !== "001"){

    return response.send(
      {
        code:10001,
        msg:`查询失败`,
        data:null
      }
    )
  
  }





  
  response.send({
    code:10000,
    msg:`查询成功`,
    data:{
      name:"Firo",
      age:18,
      sex:`🚹`
    }
  })


})



//静态资源借口
app.get(`/1`,(req,res)=>{

  const filePath = path.resolve(__dirname,`./axios.html`)

  res.sendFile(filePath)
})




app.listen(3000,()=>{

  console.log(`访问服务器 http://127.0.0.1:3000`);

})
